import request from "@/utils/request";
import type {CategoryResponsData, AttrResponsData, Attr} from "./type";
enum API {
    C1_URL = '/admin/product/getCategory1',
    C2_URL = '/admin/product/getCategory2/',
    C3_URL = '/admin/product/getCategory3/',
    ATTR_URL = '/admin/product/attrInfoList/',
    ADDORUPDATEATTR_URL = '/admin/product/saveAttrInfo',
    DELETEATTR_URL = '/admin/product/deleteAttr/'
}

export const reqC1 = () => request.get<any, CategoryResponsData>(API.C1_URL)
export const reqC2 = (category1Id: number | string) => request.get<any, CategoryResponsData>(API.C2_URL+category1Id)
export const reqC3 = (category2Id: number | string) => request.get<any, CategoryResponsData>(API.C3_URL+category2Id)
export const reqAttr = (c1Id: number | string, c2Id: number | string, c3Id: number | string) => request.get<any, AttrResponsData>(API.ATTR_URL+`${c1Id}/${c2Id}/${c3Id}`) 
export const reqAddOrUpdateAttr = (data: Attr) => request.post<any, any>(API.ADDORUPDATEATTR_URL, data)
export const reqDeleteAttr = (id: string | number) => request.delete<any, any>(API.DELETEATTR_URL+id)